/**
 * 
 */
package edu.hadassah.store.management;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import edu.hadassah.store.client.IClient;
import edu.hadassah.store.uniqueid.IUniqueId;

/**
 * @author persikov
 *
 */
public final class Client implements IClient {

	private final IUniqueId id;
	private final String name;
	private final Set<IUniqueId> orders;
	
	
	Client (IClient other){
		this.id = other.getId();
		this.name = other.getName();
		this.orders = new HashSet<IUniqueId> (other.getAllOrdersIds());
	}
	/**
	 * @param id
	 */
	Client(IUniqueId id, String name) {
		super();
		this.id = id;
		this.name = name;
		orders = new HashSet<IUniqueId>();
	}

	/**
	 * @param id2
	 */
	void addOrder(IUniqueId orderId) {
		orders.add(orderId);
		
	}

	/**
	 * @return
	 * @see edu.hadassah.store.client.IClient#getAllOrdersIds()
	 */
	public Collection<IUniqueId> getAllOrdersIds() {
		return Collections.unmodifiableSet(orders);
	}

	/**
	 * @return
	 * @see edu.hadassah.store.client.IClient#getId()
	 */
	public IUniqueId getId() {
		return id;
	}
	/**
	 * @return
	 * @see edu.hadassah.store.client.IClient#hasOrders()
	 */
	public boolean hasOrders() {
		return !orders.isEmpty();
	}
	/**
	 * @param orderId
	 * @return
	 */
	boolean removeOrder(IUniqueId orderId) {
		return orders.remove(orderId);
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}


}
